#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;

stack<int> string_stack;
char input_string[110];
char match_result[110];

int main(int argc, char const *argv[]){
    while (scanf("%s", input_string) != EOF){
        int i;
        for (i = 0; input_string[i] != '\0'; i++){
            if (input_string[i] == '('){
                //push index to stack
                string_stack.push(i);
                //' ' for temporary
                match_result[i] = ' ';
            } else if (input_string[i] == ')'){
                if (!string_stack.empty()){
                    //match successful
                    string_stack.pop();
                    match_result[i] = ' ';
                } else
                    match_result[i] = '?';
            } else
                match_result[i] = ' ';
        }
        while (!string_stack.empty()){
            match_result[string_stack.top()] = '$';
            string_stack.pop();
        }
        match_result[i] = '\0';
        puts(input_string);
        puts(match_result);
    }
    return 0;
}